using UnityEngine;
using UnityEngine.EventSystems;

namespace Game.UI {
	public sealed class WindowDragHandler : MonoBehaviour, IDragHandler {
		UIWindow _owner;

		private void Awake() {
			_owner = GetComponentInParent<UIWindow>();
		}

		public void OnDrag(PointerEventData eventData) {
			if ( !_owner.Draggable ) {
				return;
			}
			_owner.RectTransform.anchoredPosition += new Vector2(eventData.delta.x, eventData.delta.y);
		}
	}

}
